package com.guapi.gwt.reference.client;

import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Image;
import com.guapi.gwt.parser.client.model.Content;



public class ContentDisplay extends FlexTable {

	public ContentDisplay(Content content) {
		
		int row = 0;
		
		setText(row, 0, "Headline");
		setText(row, 1, content.getHeadline());
		
		setText(++row, 0, "Url");
		Anchor link = new Anchor(content.getWebUrl(), content.getWebUrl());
		link.setTitle(content.getLinkText());
		setWidget(row, 1, link);
		
		
		if (content.getTrailImage() != null) {
			setText(++row, 0, "Trail image");
			Image image = new Image(content.getTrailImage());
			setWidget(row, 1, image);
		}
		
		
		setText(++row, 0, "Link text");
		setText(row, 1, content.getLinkText());
		
		
		if (content.getStandfirst() != null) {
			setText(++row, 0, "Standfirst");
			setText(row, 1, content.getStandfirst());
		}
		
		if (content.getTrailText() != null) {
			setText(++row, 0, "Trail text");
			setText(row, 1, content.getTrailText());
		}
		
		if (content.getBody() != null) {
			setText(++row, 0, "Body text");
			setHTML(row, 1, content.getBody());
		}
				
		for (int x = 0; x < row + 1; x++) {
			getCellFormatter().setStyleName(x, 0, "label");
		}
	}

}
